PORT=8090
NAME=spring-boot-study
LOGPATH=/work/appdata/logs/info.txt
#项目部署
deploy(){
        #进入到代码目录
        cd /work/code/java
        #删除原有目录
        if [ $NAME ]
        then
                rm -rf $NAME
        fi
        ls
        pwd
        #从git拉取项目
        echo "ready to clone project from git"
        git clone https://gitee.com/difficult/spring-boot-study.git
        echo "config project: $NAME has finished"
        #进入到该项目
        cd $NAME
        #maven打包
        echo "ready to mvn package"
        mvn clean package -Dmaven.test.skip=true
        echo "maven package work has finished"
        cd target
        pwd
        #关闭该端口原有的进程
        PID=$(netstat -nlp | grep :$PORT | awk '{print $7}' | awk -F"/" '{print $1}')
        if [ $PID ]
        then
                kill -9 $PID
        fi
        #启动该服务
        java -jar personal.jar > $LOGPATH &
}
#项目开始部署
echo "ready to employee project"
deploy
echo "finished"